// requestInterceptor.js
export function setupRequestInterceptor() {
  uni.addInterceptor('request', {
    invoke(args) {
      const token =  sessionStorage.getItem('token') || '';

      if (token) {
        args.header = args.header || {};
        args.header.Authorization = `Bearer ${token}`;
      }

      return args;
    },
    fail(err) {
      console.error('请求失败:', err);
    },
  });
}
